local thbattle__lingmeng_nafeng_rule = fk.CreateSkill {

  name = "thbattle__lingmeng_nafeng_rule&",

  tags = {  },

}



thbattle__lingmeng_nafeng_rule:addEffect("active", {
  prompt = function(self, player, selected_cards, selected_targets)
    local target
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      if p:hasSkill("thbattle__lingmeng_nafeng$") and p.role == "lord" then
        target = p
        break
      end
    end
    return "#thbattle__lingmeng_nafeng_rule&:" .. target.id
  end,
  anim_type = "support",
  card_num = 1,
  card_filter =function (self, player, to_select, selected)
    return #selected == 0 and table.contains(player:getCardIds("h"), to_select)
  end,
  target_num = 1,
  target_filter =function (self, player, to_select, selected, selected_cards, card, extra_data)
    return #selected == 0 and to_select ~= player and
        to_select:hasSkill("thbattle__lingmeng_nafeng$")
        and to_select.role == "lord"
  end,
  can_use = function(self, player, card, extra_data)
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      if p:hasSkill("thbattle__lingmeng_nafeng$") and p.role == "lord" then
        return player:usedSkillTimes(thbattle__lingmeng_nafeng_rule.name, Player.phase) == 0 and #p:getCardIds("h") < p.maxHp
      end
    end
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:broadcastPlaySound("packages/thbattle/audio/skill/thbattle__lingmeng_nafeng$" .. math.random(2, 3))
    room:moveCardTo(effect.cards, Card.PlayerHand, target, fk.ReasonGive, thbattle__lingmeng_nafeng_rule.name, nil, true, player,
      "@@thb_mingpai")
  end,
})

return thbattle__lingmeng_nafeng_rule